<template>
  <my-layout sTitle="装饰优品" :isShowLeft="false">
    <div slot="content" class="w-index">
      <search :slideList="dataSlideList"/>
      <hot :hotList="dataHotList"/>
      <recommend :roomList="roomList" @getRoom="getProgRoom" :total="total"/>
    </div>
    <my-footer slot="footers"/>
  </my-layout>
</template>

<script>
import search from "./components/search";
import hot from "./components/hot";
import recommend from "./components/recommend";
export default {
  components: {
    search,
    hot,
    recommend
  },
  data() {
    return {
      dataSlideList: [],
      dataHotList: [],
      roomList: [],
      pageData: {
        pageNum: 1,
        pageSize: 1
      },
      total: 0
    };
  },
  methods: {
    // 轮播图
    async getSlidePic() {
      const { data } = await this.$http.post("material/finds", {
        location: "hpage_piclist"
      });
      if (data.code == 0) {
        this.dataSlideList = data.materials;
      } else {
      }
    },
    // 热门
    async getHotpic() {
      const { data } = await this.$http.post("lp/hot", {});
      if (data.code == 0) {
        this.dataHotList = data.lps;
      } else {
      }
    },
    // 样板间
    async getProgRoom() {
      const { data } = await this.$http.post("prog/finds", {
        pageNum: this.pageData.pageNum++,
        pageSize: 1
      });
      if (data.code == 0) {
        this.total = data.total;
        this.roomList.push(...data.progs);
      }
    },
    async gettotal() {
      const { data } = await this.$http.post("prog/finds", {
        pageNum: 1,
        pageSize: 1
      });
      if (data.code == 0) {
        this.info = data;
        this.total = data.total;
      }
    }
  },
  mounted() {
    this.getSlidePic();
    this.getHotpic();
    // this.getProgRoom();
    this.gettotal();
  }
};
</script>

<style lang="scss">
.w-index {
  background: #f7f7f7;
}
</style>
